#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#define chardev_path "/dev/cdev"

void main (int argc, char *argv[])
{
    int fd;
    char buf[1024];

    fd = open(chardev_path, O_RDWR);
    if (0 == strcmp(argv[1],"w")){
        write(fd, argv[2], strlen(argv[2]+1));
    }else if (0 == strcmp(argv[1],"r")){
        read(fd, buf, 1024);
        buf[1023] = '\0';
        printf("APP read : %s\n", buf);
    }else{
        printf("something error\n");
    }
    close(fd);
}